<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>保证金抵扣流程附加页面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <form id="formSet1">
            <div class="fieldset1 tabel_col clearFix">
                <div class="caption">
                    <div class="btnsBox posR">
                    </div>
                    <span>&nbsp;</span>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">融资租赁合同号</div>
                    <div class="field">
                        <span>${prj.lsCntNo}</span>
                        <input name="paySchId" id="paySchId" type="hidden" class="ui-textbox" value="${paySchId}">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">承租人</div>
                    <div class="field">
                        <span>${cst.cstNm }</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <a href="javascript:detailBtn()" class="link">
                            <span>${pay.paySchNo}</span>
                        </a>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">开始期次</div>
                    <div class="field">
                        <span>${startPd}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label" role="ligertip">自抵扣期剩余租金合计</div>
                    <div class="field">
		                <span>
		                <c:if test="${pay.totalRntAmt==0}">0</c:if>
		                <c:if test="${pay.totalRntAmt!=0}">
                            <fmt:formatNumber type="number" value="${pay.totalRntAmt}" pattern=".00"/>
                        </c:if>
		                </span>
                    </div>
                </div>
                <!-- -->
                <div class="fieldBox col_50">
                    <div class="label">客户保证金</div>
                    <div class="field">
		                <span>
                            <fmt:formatNumber type="number" value="${feeTypO2}" pattern="#.00"/>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">抵扣前应还每期租金</div>
                    <div class="field">
                        <span>${pay.getEachEstRntAmt()}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">最终抵扣期次</div>
                    <div class="field">
		                <span>
                            ${pay.lsPd}
		                </span>
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">租金抵扣类型</div>
                    <div class="field">
		                <span>
		                <c:if test="${insDeduct==0}">我司/代收代付</c:if>
		                <c:if test="${insDeduct==1}">
                            资方划扣
                        </c:if>
		                </span>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="sqPanel">
                        <div id="feePayGrid">
                            <div id="ligergrid_calculate" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合计租金</div>
                    <div class="field">
                        <span id="totalRntAmt">${pay.totalRntAmt}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合计本金</div>
                    <div class="field">
                        <span id="totalPrinAmt">${pay.totalPrinAmt}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合计利息</div>
                    <div class="field">
                        <span id="totalIntAmt">${pay.totalIntAmt}</span>
                    </div>
                </div>

            </div>
        </form>
        <c:if test="${showBk_oCIn==1 }">
            <jsp:include page="../prjPrdPaySchBank/cashDepositDeductionBankAdd.jsp"></jsp:include>
        </c:if>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $('#formSet1').ligerForm({
            validate: true
        });
        var listPage = '${listPage}';

        listPage = JsonUtils.parse(listPage);
        initCalculatePage(listPage);
    });

    function detailBtn(prjPrdDtlId, paySchId, prjPrdId, prjId) {
        var paySchTyp = '${paySchTyp}';
        var prjId = '${dtl.prjId}';
        var prjPrdDtlId = '${dtl.id}';
        var prjPrdId = '${dtl.prjPrdId}';
        var paySchId = '${paySchId}';
        var detailFlag = true;
        var zfDetailFlag = false;
        if('ZF' == paySchTyp){
            zfDetailFlag = true;
        }

        Add_navTab('tab_prj_quat_prps' + paySchId, '查看支付表', '<%=path%>/project/prjprdpayschm/toAddPage.do?prjId=' + prjId + '&&id=' + paySchId + '&&prjPrdDtlId=' + prjPrdDtlId + '&&prjPrdId=' + prjPrdId+'&detailFlag=' + detailFlag + '&zfDetailFlag='+zfDetailFlag);
    }

    //格式化为人民币格式
    function renderAmt(rowdata, rowindex, value) {
        if (null !== value && value !== 'undefined' && value !== "") {
            if (typeof Number(value) == 'number') {
                var h = "￥" + FormatMoney((parseFloat(value)).toFixed(2));
                return h;
            }
        }
    }



    function initCalculatePage(data) {
        calculateGrid = $("#ligergrid_calculate").ligerGrid({
            data: data,
            columns: [
                {display: '支付时间', name: 'payDt', render: renderDate, minWidth: 60},
                {display: '期次', name: 'payPd', minWidth: 140},
                {display: '租金', name: 'rntAmt', minWidth: 140, render: renderAmt, type: 'currency', enabledSort: true},
                {display: '本金', name: 'prinAmt', minWidth: 60, render: renderAmt, type: 'currency'},
                {display: '利息', name: 'intAmt', minWidth: 140, render: renderAmt, type: 'currency'},
                {display: '剩余本金', name: 'remPrinAmt', render: renderAmt, minWidth: 140, type: 'currency'},
            ],
            usePager: false,
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: 300,
            heightDiff: -2,
            //isScroll: false,
            checkbox: false,
            enabledEdit: false,
            rownumbers: true
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>
</body>
</html>
